<html><head><meta charset="gb2312"/><title>Mesh.pb</title></head>
<body bgcolor="#EFF1F0" link="#3A3966" vlink="#000000" alink="#000000">
<pre><font face="Courier New, Courier, mono"size="2"><font color="#3A3966">;
</font><font color="#3A3966">; ------------------------------------------------------------
</font><font color="#3A3966">;
</font><font color="#3A3966">;   PureBasic - Mesh (Skeleton Animation)
</font><font color="#3A3966">;
</font><font color="#3A3966">;    (c) 2002 - Fantaisie Software
</font><font color="#3A3966">;
</font><font color="#3A3966">; ------------------------------------------------------------
</font><font color="#3A3966">;
</font>
<b><font color="#3A3966">IncludeFile</font></b> "Screen3DRequester.pb"

<b><font color="#3A3966">Define</font></b>.f KeyX, KeyY, MouseX, MouseY

<font color="#FF0000">#RobotMesh</font>    = 0
<font color="#FF0000">#RobotTexture</font> = 0
<font color="#FF0000">#Robot</font>        = 0
  
<b><font color="#3A3966">If</font></b> <font color="#3A3966">InitEngine3D</font>()

<font color="#3A3966">  Add3DArchive</font>("Data/Textures", <font color="#FF0000">#PB_3DArchive_FileSystem</font>)
<font color="#3A3966">  Add3DArchive</font>("Data/Models", <font color="#FF0000">#PB_3DArchive_FileSystem</font>)
   
<font color="#3A3966">  InitSprite</font>()
<font color="#3A3966">  InitKeyboard</font>()
<font color="#3A3966">  InitMouse</font>()
  
  <b><font color="#3A3966">If</font></b> <font color="#3A3966">Screen3DRequester</font>()
    
<font color="#3A3966">    LoadMesh   </font>(<font color="#FF0000">#RobotMesh</font>   , "Robot.mesh")
<font color="#3A3966">    LoadTexture</font>(<font color="#FF0000">#RobotTexture</font>, "clouds.jpg")
    
<font color="#3A3966">    CreateMaterial</font>(0,<font color="#3A3966"> TextureID</font>(<font color="#FF0000">#RobotTexture</font>))
    
<font color="#3A3966">    CreateEntity</font>(<font color="#FF0000">#Robot</font>,<font color="#3A3966"> MeshID</font>(<font color="#FF0000">#RobotMesh</font>),<font color="#3A3966"> MaterialID</font>(0))
<font color="#3A3966">    SetEntityMaterial</font>(<font color="#FF0000">#Robot</font>,<font color="#3A3966"> MaterialID</font>(0))
    
<font color="#3A3966">    AnimateEntity</font>(<font color="#FF0000">#Robot</font>, "Walk")
    
<font color="#3A3966">    DisableMaterialLighting</font>(0, 1)
    
<font color="#3A3966">    MaterialAmbientColor</font>(0,<font color="#3A3966"> RGB</font>(100, 100, 100))
<font color="#3A3966">    MaterialSpecularColor</font>(0,<font color="#3A3966"> RGB</font>(255, 255, 255))
<font color="#3A3966">    ScrollMaterial</font>(0, 0.15, 0, 1)
        
<font color="#3A3966">    CreateLight</font>(0,<font color="#3A3966"> RGB</font>(0,0,255), 100.0, 0, 0)
<font color="#3A3966">    LightSpecularColor</font>(0,<font color="#3A3966"> RGB</font>(255, 0, 0))
    
<font color="#3A3966">    CreateCamera</font>(0, 0, 0, 100, 100)
<font color="#3A3966">    CameraLocate</font>(0, 0, 40, 150)
<font color="#3A3966">    CameraBackColor</font>(0,<font color="#3A3966"> RGB</font>(0, 0, 128))
      
    <b><font color="#3A3966">Repeat</font></b>
<font color="#3A3966">      Screen3DEvents</font>()
              
      <b><font color="#3A3966">If</font></b> <font color="#3A3966">ExamineKeyboard</font>()
      
        <b><font color="#3A3966">If</font></b> <font color="#3A3966">KeyboardPushed</font>(<font color="#FF0000">#PB_Key_Left</font>)
          KeyX = -1
        <b><font color="#3A3966">ElseIf</font></b> <font color="#3A3966">KeyboardPushed</font>(<font color="#FF0000">#PB_Key_Right</font>)
          KeyX = 1
        <b><font color="#3A3966">Else</font></b>
          KeyX = 0
        <b><font color="#3A3966">EndIf</font></b>
        
        <b><font color="#3A3966">If</font></b> <font color="#3A3966">KeyboardPushed</font>(<font color="#FF0000">#PB_Key_Up</font>)
          KeyY = -1
        <b><font color="#3A3966">ElseIf</font></b> <font color="#3A3966">KeyboardPushed</font>(<font color="#FF0000">#PB_Key_Down</font>)
          KeyY = 1
        <b><font color="#3A3966">Else</font></b>
          KeyY = 0
        <b><font color="#3A3966">EndIf</font></b>
        
        <b><font color="#3A3966">If</font></b> <font color="#3A3966">KeyboardPushed</font>(<font color="#FF0000">#PB_Key_PageUp</font>)
          RollZ = 3
        <b><font color="#3A3966">Else</font></b>
          RollZ = 0
        <b><font color="#3A3966">EndIf</font></b>
        
        <b><font color="#3A3966">If</font></b> <font color="#3A3966">KeyboardPushed</font>(<font color="#FF0000">#PB_Key_Add</font>)
          Frame.f+0.005
        <b><font color="#3A3966">EndIf</font></b>
        
      <b><font color="#3A3966">EndIf</font></b>
      
      <b><font color="#3A3966">If</font></b> <font color="#3A3966">ExamineMouse</font>()
        MouseX = -<font color="#3A3966">MouseDeltaX</font>()/10 
        MouseY = -<font color="#3A3966">MouseDeltaY</font>()/10
      <b><font color="#3A3966">EndIf</font></b>
      
<font color="#3A3966">      RotateEntity</font>(<font color="#FF0000">#Robot</font>, 0, 1, 0, <font color="#FF0000">#PB_Relative</font>)
      
<font color="#3A3966">      RotateCamera</font>(0, MouseY, MouseX, RollZ, <font color="#FF0000">#PB_Relative</font>)
<font color="#3A3966">      MoveCamera  </font>(0, KeyX, 0, KeyY)
      
<font color="#3A3966">      RenderWorld</font>()
<font color="#3A3966">      Screen3DStats</font>()
<font color="#3A3966">      FlipBuffers</font>()
    <b><font color="#3A3966">Until</font></b> <font color="#3A3966">KeyboardPushed</font>(<font color="#FF0000">#PB_Key_Escape</font>) <b><font color="#3A3966">Or</font></b> Quit = 1
  <b><font color="#3A3966">EndIf</font></b>
    
<b><font color="#3A3966">Else</font></b>
<font color="#3A3966">  MessageRequester</font>("Error", "The 3D Engine can't be initialized",0)
<b><font color="#3A3966">EndIf</font></b>
  
<b><font color="#3A3966">End</font></b><font color="#FF0000">'$</font></font></pre>
</body></html>
